package common.ctrl.impl;

import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import javax.swing.AbstractAction;
import javax.swing.JList;
import javax.swing.JTextArea;

import common.ctrl.IObserver;
import common.gui.IViewable;
import common.i18n.ChangeLanguage;

@SuppressWarnings("serial")
public class HelpCtrl extends AbstractAction implements IObserver, MouseListener {

        public final static String HELP_DIALOG_CTRL = "help";
        
        @Override
        public void mouseClicked(MouseEvent e) {
                JList topics = (JList) this.getValue("HelpDialog.topics");
                JTextArea text = (JTextArea) this.getValue("HelpDialog.text");
                text.setText("");
                String f = File.separator;
                String fileName = 
                        "." + f + 
                        "resource" + f +
                        "languages" + f + 
                        "help_" + 
                        ChangeLanguage.currentLanguage.getString("language") + f +
                        (String)topics.getSelectedValue() + ".help";
                
                
                try {
                        Scanner sc = new Scanner(new File(fileName));
                        while(sc.hasNext()) {
                                text.append(sc.nextLine() + "\n");
                        }
                } catch (FileNotFoundException e1) {
                }
                
        }
        
        @Override
        public void actionPerformed(ActionEvent e) {
                
                
        }
        
        @Override
        public void addView(IViewable iv) {
                // TODO Auto-generated method stub

        }

        @Override
        public void mouseEntered(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void mouseExited(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void mousePressed(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
        }

        @Override
        public void mouseReleased(MouseEvent arg0) {
                // TODO Auto-generated method stub
                
        }

        
}